package com.api.gbhg.xxd.api;

import com.alibaba.fastjson.JSON;
import com.api.gbhg.xxd.dao.ReimbursementDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import weaver.conn.RecordSet;

import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Path("/BaoXiaoJiLu")
public class BaoXiaoJiLu {


    //private static final Logger logger = LoggerFactory.getLogger(BaoXiaoJiLu.class);
    private static final Logger logger = LoggerFactory.getLogger("gbhg");
    @POST
    @Produces(MediaType.APPLICATION_JSON)
    @Path("/baoXiaoJiLuList")
    public String baoXiaoJiLuList(Map<String, Object> map) {

        logger.info("进入/BaoXiaoJiLu/baoXiaoJiLuList接口");
        String dw = map.getOrDefault("dw", "").toString();  //单位
        String startTime = map.getOrDefault("startTime", "").toString();    //开始日期
        String endTime = map.getOrDefault("endTime", "").toString();    //结束日期
        String agent = map.getOrDefault("agent", "").toString();
        String year = map.getOrDefault("year", "").toString();  //年份
        String requestId = map.getOrDefault("requestId", "").toString();
        String jbrId = map.getOrDefault("jbrId", "").toString();
        String startMoney = map.getOrDefault("startMoney","").toString();
        String endMoney = map.getOrDefault("endMoney","").toString();
        List<Map<String, Object>> list = new ArrayList<>();

        logger.info("参数：jbrId：" + jbrId + ",dw:" + dw + ",startTime:" + startTime + ",endTime:" + endTime + ",agent:" + agent);
        //已办
        RecordSet filter1 = ReimbursementDao.filter(agent, startTime, endTime, dw, year, requestId, jbrId);
        while (filter1.next()) {
            Map<String, Object> mapdate = ReimbursementDao.workflowinfo(filter1.getStringNoTrim("requestid")
                    , filter1.getStringNoTrim("requestname"),startMoney,endMoney);
            if (!mapdate.isEmpty()) {
                list.add(mapdate);
            }
        }
        return JSON.toJSONString(list);

    }
}
